<template>
  <div class="accountsubsidy">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="征地项目:">
        <el-select
          v-model="value"
          value-key="Id"
          placeholder="请选择"
          @change="overChange()"
        >
          <el-option
            v-for="item in options"
            :key="item.Id"
            :label="
              item.township +
              '--' +
              item.Village +
              '--' +
              item.YearNum +
              '--' +
              item.ProjectName
            "
            :value="item.Id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="申请单:">
        <el-select v-model="value1" placeholder="请选择" @change="hideChange()">
          <el-option
            v-for="item in option"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="申请单号:" v-show="showApply">
        <el-select v-model="cardNum" placeholder="请选择">
          <el-option
            v-for="item in optionInfo"
            :key="item.ApplyID"
            :label="item.ApplyGroupid"
            :value="item.ApplyID"
          >
          </el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item>
        <el-button type="" @click="onSubmit" class="el-icon-search"
          >查询</el-button
        >
        <!-- <el-button
          type=""
          @click="voPre"
          class="el-icon-s-management"
          v-show="showBtn"
          >申请</el-button
        > -->
        <el-button
          type=""
          @click="voPre"
          v-show="showBtn"
          class="el-icon-printer"
          >勾选制单</el-button
        >
        <el-button
          type=""
          class="el-icon-printer"
          v-show="showBtn"
          @click="allArrival"
          >全部制单</el-button
        >
        <el-button
          type=""
          class="el-icon-printer"
          v-show="!showBtn"
          @click="printSomething"
          >打印</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 表单 -->
    <el-table
      :data="
        tableData.slice((currentPage - 1) * pagesize, currentPage * pagesize)
      "
      border
      height="calc(100vh - 350px)"
      @selection-change="handleSelectionChange"
      @sort-change="changeSort"
      :default-sort="{ prop: 'IdentityNum', order: 'ascending' }"
      :header-cell-style="{ 'text-align': 'center' }"
      :cell-style="{ 'text-align': 'center' }"
      :row-style="{ height: '48px' }"
    >
      <el-table-column type="selection" fixed="left" width="55">
      </el-table-column>
      <!-- <el-table-column fixed="left" label="操作" width="80">
        <template slot-scope="scope">
          <div v-if="scope.row.ApplyGroupid == ''">
            <el-button type="text" size="small" @click="modify(scope.row)"
              >到账</el-button
            >
          </div>
        </template>
      </el-table-column> -->
      <el-table-column type="index" width="50" />
      <el-table-column prop="Name" label="姓名" width="100"> </el-table-column>
      <el-table-column prop="GenderCode" label="性别" width="100">
        <template slot-scope="scope">
          <div>
            {{ scope.row.GenderCode == 2 ? "女" : "男" }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="IdentityNum" label="身份证号" sortable width="180">
      </el-table-column>
      <el-table-column
        prop="LandExpropriatedAge"
        label="年龄"
        sortable
        width="100"
      >
      </el-table-column>
      <el-table-column prop="AccountMoney" label="到账金额" width="150">
        <template slot-scope="scope">
          {{ number_format(scope.row.AccountMoney, 2) }}
        </template>
      </el-table-column>
      <el-table-column prop="OperName" label="录入人员" width="130">
      </el-table-column>
      <el-table-column prop="OperTime" label="录入时间" width="200">
        <template slot-scope="scope">{{
          formatDate(scope.row.OperTime)
        }}</template>
      </el-table-column>

      <el-table-column prop="ReviewName" label="审核人" width="130">
      </el-table-column>
      <el-table-column prop="ReviewTime" label="审核时间" width="200">
        <template slot-scope="scope">{{
          formatDate(scope.row.ReviewTime)
        }}</template>
      </el-table-column>
      <el-table-column prop="ApplyName" label="制单人员" width="130">
      </el-table-column>
      <el-table-column prop="ApplyTime" label="制单时间" width="200">
        <template slot-scope="scope">{{
          formatDate(scope.row.ApplyTime)
        }}</template>
      </el-table-column>
      <el-table-column
        prop="InterestMoney"
        label="计息金额"
        width="150"
        style="text-align: right"
      >
        <template slot-scope="scope">
          {{ number_format(scope.row.InterestMoney, 2) }}
        </template>
      </el-table-column>
      <el-table-column prop="FinanceStatus" label="到账状态" width="87">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 50, 100, 200]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="this.tableData.length"
    >
    </el-pagination>
    <el-form :model="ruleForm" :inline="true" class="demo-form-inline third">
      <el-form-item label="人数:" label-width="101px">
        <el-input
          v-model="ruleForm.prople"
          placeholder="--"
          disabled
        ></el-input>
      </el-form-item>
      <el-form-item label="补贴金额:" label-width="101px">
        <el-input v-model="ruleForm.zbtje" placeholder="--" disabled></el-input>
      </el-form-item>
      <el-form-item label="计息金额：">
        <el-input
          placeholder=""
          v-model="jiximoney"
          :disabled="true"
          style="text-align: right; align: right"
        >
        </el-input>
      </el-form-item>
    </el-form>

    <div class="row" id="printTest" style="visibility: hidden">
      <div id="div1">
        <div class="title" style="text-align: center">
          <h3
            id="PageTitle"
            class="text-center"
            style="border-collapse: collapse; margin-left: 0pt"
          >
            被征地农民参保补贴账户补贴到账申请单（职保）
          </h3>
        </div>
        <table width="100%">
          <tr>
            <td style="border: none; font-size: 8pt">
              <p>
                <span>用地项目名称:</span
                ><span id="ProjectName">{{ this.dataInfo.ProjectName }}</span>
              </p>
            </td>
            <td style="text-align: left; border: none; font-size: 8pt">
              <p><span id="ProjectName"></span></p>
            </td>
            <td></td>
            <td style="text-align: right; font-size: 8pt">
              <span tdata="pageNO" format="#">第#页</span>/<span
                tdata="pageCount"
                format="#"
                >总##页</span
              >
            </td>
          </tr>
        </table>
      </div>
      <div id="div2">
        <table style="border: 1px solid; table-layout: fixed" width="100%">
          <tr>
            <td style="text-align: center; width: 75pt">
              <p>
                <span>所属乡(镇、园区)</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="township">{{ this.dataInfo.township }}</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span>所属村</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="Village">{{ this.dataInfo.Village }}</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p><span>批准用地日期</span></p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="ApprovedDate">{{ this.ApprovedDate }}</span>
              </p>
            </td>
          </tr>
          <tr>
            <td style="text-align: center; width: 75pt">
              <p>
                <span>年度</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="YearNum">{{ this.dataInfo.YearNum }}</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span>批次</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="BatchNum">{{ this.dataInfo.BatchNum }}</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span>批准用地面积</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="ApprovedArea"
                  >{{ number_format(this.dataInfo.ApprovedArea, 2) }}亩</span
                >
              </p>
            </td>
          </tr>
          <tr>
            <td style="text-align: center; width: 75pt">
              <p><span>被征地农民户数</span></p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="HouseholdCount"
                  >{{ this.dataInfo.HouseholdCount }}户
                </span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p><span>征缴比例</span></p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="LevyScale">{{
                  (this.dataInfo.LevyScale * 100).toFixed(2) + "%"
                }}</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span>区片价</span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="RegionPrice"
                  >{{ number_format(this.dataInfo.RegionPrice, 2) }}元</span
                >
              </p>
            </td>
          </tr>
          <tr>
            <td style="text-align: center; width: 75pt">
              <p><span>被征地农民人数</span></p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p>
                <span id="FarmerCount">{{ this.dataInfo.FarmerCount }}人 </span>
              </p>
            </td>
            <td style="text-align: center; width: 75pt">
              <p><span>社会保险费</span></p>
            </td>
            <td style="text-align: center; width: 255pt">
              <p>
                <span style="text-align: right" id="SecurityAmount"
                  >{{ number_format(this.dataInfo.SecurityAmount, 2) }}元
                </span>
              </p>
            </td>
          </tr>
        </table>
      </div>
      <div id="div3">
        <table style="border: 1px solid; table-layout: fixed" width="100%">
          <thead>
            <tr>
              <td style="text-align: center; height: 26px; width: 16pt">
                序号
              </td>
              <td style="text-align: center; height: 26px; width: 24pt">
                姓名
              </td>
              <td style="text-align: center; height: 26px; width: 16pt">
                性别
              </td>
              <td style="text-align: center; height: 26px; width: 73pt">
                身份证号
              </td>
              <td style="text-align: center; height: 26px; width: 20pt">
                年龄
              </td>
              <td style="text-align: center; height: 26px; width: 45pt">
                基准<br />补贴年限
              </td>
              <td style="text-align: center; height: 26px; width: 45pt">
                享受困难<br />补贴年限
              </td>
              <td style="text-align: center; height: 26px; width: 45pt">
                职工养老<br />缴费年限
              </td>
              <td style="text-align: center; height: 26px; width: 45pt">
                实际补贴年限
              </td>
              <td style="text-align: center; height: 26px; width: 45pt">
                实际补贴金额
              </td>
              <td style="text-align: center; height: 26px; width: 20pt">
                计息金额
              </td>
            </tr>
          </thead>
          <tbody id="detail">
            <tr v-for="(item, index) in tableList" :key="index">
              <td
                style="
                  text-align: center;
                  width: 16pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ index + 1 }}
              </td>
              <td
                style="
                  text-align: left;
                  width: 24pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ item.Name }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 16pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ item.GenderCode == 2 ? "女" : "男" }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 73pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ item.IdentityNum }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 20pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ item.LandExpropriatedAge }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 45pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{
                  item.BasicSubsidyYears == 0
                    ? "-"
                    : yearjs(item.BasicSubsidyYears)
                }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 45pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{
                  item.PovertySubsidyYears == 0
                    ? "-"
                    : yearjs(item.PovertySubsidyYears)
                }}
              </td>

              <td
                style="
                  text-align: center;
                  width: 45pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{
                  item.CompanyPaymentYears == 0
                    ? "-"
                    : yearjs(item.CompanyPaymentYears)
                }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 45pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ yearjs(item.FinalSubsidyYears) }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 45pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ number_format(item.SubsidyMoney, 2) }}
              </td>
              <td
                style="
                  text-align: center;
                  width: 20pt;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
              >
                {{ number_format(item.InterestMoney, 2) }}
              </td>
            </tr>
          </tbody>
          <tr>
            <td
              colspan="3"
              style="
                text-align: center;
                width: 40pt;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
            >
              小计金额
            </td>
            <td
              colspan="6"
              style="
                text-align: center;
                width: 289pt;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
            ></td>
            <td
              style="
                text-align: right;
                width: 45pt;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
            >
              {{ ruleForm.zbtje }}
            </td>
            <td
              style="
                text-align: right;
                width: 20pt;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
              id="SumMoney"
            >
              {{ jiximoney }}
            </td>
          </tr>
          <tr>
            <td
              colspan="3"
              style="
                text-align: center;
                width: 40pt;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
            >
              总计金额
            </td>
            <td
              colspan="8"
              style="text-align: right; width: 354pt"
              id="SumMoney"
            >
              {{ jixi }}
            </td>
          </tr>
          <tr>
            <td
              colspan="3"
              style="
                text-align: center;
                width: 40pt;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
            >
              总计金额（大写）
            </td>
            <td
              colspan="8"
              style="text-align: left; width: 354pt"
              id="CSumMoney"
            >
              {{ this.Capitalization }}
            </td>
          </tr>
          <tr>
            <td colspan="4" style="width: 150pt">经办人：</td>
            <td colspan="4" style="width: 150pt">审核人：</td>
            <td colspan="3" style="width: 150pt">负责人：</td>
          </tr>
        </table>
      </div>
      <div id="div4">
        <table style="border: 0px solid" width="100%">
          <tr>
            <td style="text-align: left; font-size: 8pt">
              制单人：{{ this.user_name }}
            </td>
            <td></td>
            <td style="text-align: left; font-size: 8pt">
              制单时间:{{ dateToString(new Date()) }}
            </td>
            <td></td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</template>

<script>
// import moneyBig from"../../utils/moneyBig.js"
// Vue.prototype.$moneyBig = moneyBig;
import { getLodop } from "@/assets/utils/LodopFuncs";
import { API_GET_LAND, API_GET_BYID } from "../../api/table";
import {
  API_GET_LIST,
  API_APPLY,
  API_GETV_ID,
  API_FINANCE,
  API_ACC_APP,
  API_FIN_GETID,
  API_FIN_GET,
  API_DAYIN_GET,
} from "../../api/Voucherpreparation";
export default {
  name: "",
  data() {
    return {
      pagesize: 10, //每页的数据条数
      currentPage: 1,
      msg: "账户补贴制单（职保）",
      ruleForm: {},
      options: [], // 征地项目
      option: [
        {
          value: "-1",
          label: "未制单",
        },
      ],
      optionInfo: [],
      value: "",
      value1: "-1",
      cardNum: "",
      tableData: [],
      tableList: [],
      multipleSelection: [], // 选中数据合集
      currentPage3: 1,
      showApply: false, // 申请单号展示
      showBtn: true, // 申请按钮展示
      user_name: "",
      nowTime: "",
      dataInfo: {},
      ApprovedDate: "",
      Capitalization: "",
      jiximoney: null,
      jixi: "",
      xiaoji: "",
    };
  },
  methods: {
    // 月转化为年显示
    yearjs(num) {
      if ((num % 12 != 0) & (num > 12)) {
        return parseInt(num / 12) + "年" + (num % 12) + "月";
      } else if (num < 12) {
        return num + "月";
      } else {
        return parseInt(num / 12);
      }
    },
    // 打印
    printSomething() {
      console.log(this.value);
      let data = { groupid: this.value1 };
      if (this.tableData.length != 0) {
        API_DAYIN_GET(data)
          .then((res) => {
            // console.log(res);
            this.tableList = res.ResList;
          })
          .catch((err) => {
            // console.log(err);
          })
          .then((_) => {
            var LODOP;
            this.PrintMytable();
          });
      } else {
        this.$message.warning("请先查询有效数据！");
      }
      // setTimeout((_) => {
      //   // this.PrintMytable();
      // }, 1000);
    },
    PrintMytable() {
      LODOP.PRINT_INIT("被征地农民参加基本养老保险情况统计表");
      var strStyle =
        "<style> table,td,th {border-width: 1px;border-style: solid;border-collapse: collapse}span{  font-size:8pt ;text-align:left;margin-top:5px;margin-left:15px;}td{font-size:8pt ;padding:5px;}</style>";
      LODOP.ADD_PRINT_HTM(
        26,
        "5%",
        "90%",
        109,
        document.getElementById("div1").innerHTML
      );
      LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
      LODOP.SET_PRINT_STYLEA(0, "LinkedItem", 1);
      LODOP.ADD_PRINT_TABLE(
        100,
        "5%",
        "RightMargin:1cm",
        400,
        strStyle + document.getElementById("div2").innerHTML
      );
      LODOP.SET_PRINT_STYLEA(0, "Vorient", 3);
      LODOP.ADD_PRINT_TABLE(
        193,
        "5%",
        "RightMargin:1cm",
        "BottomMargin:1cm",
        strStyle + document.getElementById("div3").innerHTML
      );
      LODOP.SET_PRINT_STYLEA(0, "Offset2Top", -100);
      LODOP.ADD_PRINT_HTM(
        "280mm",
        "15mm",
        "200mm",
        "2cm",
        document.getElementById("div4").innerHTML
      );
      LODOP.SET_PRINT_STYLEA(0, "ItemType", 1);
      LODOP.SET_PRINT_STYLEA(0, "LinkedItem", 4);
      //LODOP.SET_PRINT_STYLEA(0, "VOrient", 1);
      LODOP.PREVIEW();
    },
    // 排序
    changeSort(val) {
      console.log(val); // column: {…} order: "ascending" prop: "date"
      // 根据当前排序重新获取后台数据,一般后台会需要一个排序的参数
    },
    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pagesize = val;
    },
    handleCurrentChange(currentPage) {
      // console.log(`当前页: ${val}`);
      this.currentPage = currentPage;
    },
    // 单独到账
    modify(row) {
      let data = {
        Id: row.Id,
        Farmerid: row.Farmerid,
      };
      API_APPLY(data)
        .then((res) => {
          console.log(res);
          this.$message.success("制单成功！");
          this.overChange();
          this.finge();
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 全部制单
    allArrival() {
      if (this.tableData.length != 0) {
        let data = { Landid: this.value, stype: 2 };
        API_ACC_APP(data)
          .then((res) => {
            console.log(res);
            this.overChange();
            this.$message.success("制单成功！");
            this.finge();
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        this.$message.warning("请先查询");
      }
    },
    hideChange() {
      if (this.value1 == "-1") {
        this.showBtn = true;
      } else {
        this.showBtn = false;
      }
      this.tableData = [];
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    voPre() {
      console.log(this.multipleSelection);
      let data = this.multipleSelection.map((item) => {
        return {
          Id: item.Id,
          Farmerid: item.Farmerid,
        };
      });
      console.log(data);
      if (data.length != 0) {
        API_APPLY(data)
          .then((res) => {
            console.log(res);
            this.$message.success("制单成功！");
            this.overChange();
            this.finge();
            // this.value1 = res.ResMesssage;
            // this.cardNum = res.ResMesssage;
            // this.showApply = true;
            // this.showBtn = false;
          })
          .catch((err) => {
            console.log(err);
          });
      } else {
        this.$message({
          message: "请选择数据！",
          type: "warning",
        });
      }
    },
    formatDate(time) {
      if (time != "") {
        if (time.toString().substr(6, 13) < 0) {
          return "";
        } else {
          return this.timeD(new Date(parseInt(time.toString().substr(6, 13))));
        }
      }
    },
    timeD(date) {
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      var d = date.getDate();
      d = d < 10 ? "0" + d : d;
      var h = date.getHours();
      h = h < 10 ? "0" + h : h;
      var minute = date.getMinutes();
      minute = minute < 10 ? "0" + minute : minute;
      var second = date.getSeconds();
      second = second < 10 ? "0" + second : second;
      return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
    },
    formDate(time) {
      if (time != "") {
        return new Date(
          parseInt(time.toString().substr(6, 13))
        ).toLocaleDateString();
      }
    },
    // 时间戳格式化
    dateToString(date) {
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      var d = date.getDate();
      d = d < 10 ? "0" + d : d;
      var h = date.getHours();
      h = h < 10 ? "0" + h : h;
      var minute = date.getMinutes();
      minute = minute < 10 ? "0" + minute : minute;
      var second = date.getSeconds();
      second = second < 10 ? "0" + second : second;
      return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
    },
    onSubmit() {
      // console.log("submit!");
      if (this.value1 == -1) {
        // console.log("未制单");
        this.showBtn = true;
        // this.getuserId();
        this.fingetid();
        this.$message.success("数据查询成功！");
      } else {
        // if (this.cardNum != "") {
        // this.getuserInfo();
        // } else {
        // this.$message({
        // message: "请选择申请单号！",
        // type: "warning",
        // });
        // }
        this.finget();
        // this.dayin();
        this.details();
        this.$message.success("数据查询成功！");
      }
    },
    formatTime(time) {
      if (time != "") {
        if (time.toString().substr(6, 13) < 0) {
          return "";
        } else {
          return this.timeC(new Date(parseInt(time.toString().substr(6, 13))));
        }
      }
    },
    timeC(date) {
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      var d = date.getDate();
      d = d < 10 ? "0" + d : d;
      var h = date.getHours();
      h = h < 10 ? "0" + h : h;
      var minute = date.getMinutes();
      minute = minute < 10 ? "0" + minute : minute;
      var second = date.getSeconds();
      second = second < 10 ? "0" + second : second;
      return y + "年" + m + "月" + d + "日";
    },
    details() {
      let data = {
        lid: this.value,
      };
      API_GET_BYID(data)
        .then((res) => {
          this.dataInfo = res.ResList[0];
          console.log(this.dataInfo);
          this.ApprovedDate = this.formatTime(res.ResList[0].ApprovedDate);
          // this.Capitalization = this.$moneyBig.proof(this.ruleForm.zbtje);
          // this.Capitalization = this.$moneyBig.required(
          //   res.ResList[0].SecurityAmount
          // );
        })
        .catch((err) => {
          console.log(err);
        });
    },
    dayin() {
      let data = { groupid: this.value1 };
      API_DAYIN_GET(data)
        .then((res) => {
          // console.log(res);
          this.tableList = res.ResList;
        })
        .catch((err) => {
          // console.log(err);
        });
    },
    Submit() {
      // console.log("submit!");
      if (this.value1 == -1) {
        // console.log("未制单");
        this.showBtn = true;
        // this.getuserId();
        this.fingetid();
        // this.$message.success("数据刷新成功！");
      } else {
        // if (this.cardNum != "") {
        // this.getuserInfo();
        // } else {
        // this.$message({
        // message: "请选择申请单号！",
        // type: "warning",
        // });
        // }
        this.finget();
      }
    },
    // handleSizeChange(val) {
    //   console.log(`每页 ${val} 条`);
    // },
    // handleCurrentChange(val) {
    //   console.log(`当前页: ${val}`);
    // },
    // 选中申请单触发
    overChange() {
      // if (this.value != "" && this.value1 != "") {
      //   if (this.value1 == 1) {
      //     // console.log("未制单");
      //     this.showApply = false;
      //     this.showBtn = true;
      //   } else if (this.value1 == 0) {
      //     this.showApply = true;
      //     this.showBtn = false;
      //   }
      // }
      this.abc();
    },
    // 查询人员信息
    getuserInfo() {
      let data = {
        id: this.value,
        stype: 2,
        ApplyType: this.value1,
        Applyid: "",
      };
      API_GETV_ID(data)
        .then((res) => {
          console.log(res);
          this.tableData = res.ResList;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    getuserId() {
      let data = {
        id: this.value,
        stype: 2,
        ApplyType: 1,
        Applyid: "",
      };
      API_GETV_ID(data)
        .then((res) => {
          this.tableData = res.ResList;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    fingetid() {
      let data = {
        landid: this.value,
        stype: 2,
      };
      API_FIN_GETID(data)
        .then((res) => {
          this.tableData = res.ResList;
          this.ruleForm.prople = this.tableData.length;
          let a = 0,
            b = 0;
          this.tableData.map((item, index) => {
            // console.log(Number(item.SubsidyMoney));
            a += Number(this.tableData[index].AccountMoney);
            b += Number(this.tableData[index].InterestMoney);
          });
          this.Capitalization = this.$moneyBig.required(a.toFixed(2));
          this.ruleForm.zbtje = this.number_format(a, 2);
          // console.log(this.ruleForm.zbtje);
          console.log(b);
          this.jiximoney = this.number_format(b, 2);
          this.jixi = this.number_format(b + a, 2);
          // this.jixi = this.number_format(b + this.ruleForm.zbtje, 2);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 刷新
    finge() {
      let data = {
        landid: this.value,
        stype: 2,
      };
      API_FIN_GETID(data)
        .then((res) => {
          console.log(res);
          this.$message.success("数据刷新成功！");
          this.tableData = res.ResList;
          this.ruleForm.prople = this.tableData.length;
          let a = 0,
            b = 0;
          this.tableData.map((item, index) => {
            // console.log(Number(item.SubsidyMoney));
            a += Number(this.tableData[index].AccountMoney);
            b += Number(this.tableData[index].InterestMoney);
          });
          this.Capitalization = this.$moneyBig.required(a.toFixed(2));
          this.ruleForm.zbtje = this.number_format(a, 2);
          // console.log(this.ruleForm.zbtje);
          console.log(b);
          this.jiximoney = this.number_format(b, 2);
          this.jixi = this.number_format(b + a, 2);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    finget() {
      let data = {
        Applyid: this.value1,
        stype: 2,
        ApplyType: 0,
      };
      API_FIN_GET(data)
        .then((res) => {
          console.log(res);
          this.tableData = res.ResList;
          this.ruleForm.prople = this.tableData.length;
          let a = 0,
            b = 0;
          this.tableData.map((item, index) => {
            // console.log(Number(item.SubsidyMoney));
            a += Number(this.tableData[index].AccountMoney);
            b += Number(this.tableData[index].InterestMoney);
          });
          this.Capitalization = this.$moneyBig.required(a.toFixed(2));
          this.ruleForm.zbtje = this.number_format(a, 2);
          // console.log(this.ruleForm.zbtje);
          console.log(b);
          this.jiximoney = this.number_format(b, 2);
          this.jixi = this.number_format(b + a, 2);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    abc() {
      this.value1 = "-1";
      let data = {
        landid: this.value,
        stype: 2,
        Atype: 0,
      };
      this.option = [
        {
          value: "-1",
          label: "未制单",
        },
      ];
      // console.log(data);
      API_GET_LIST(data)
        .then((res) => {
          console.log(res);
          this.optionInfo = res.ResList;
          res.ResList.map((item) => {
            this.option.push({
              value: item.ApplyGroupid,
              label: item.ApplyGroupid,
            });
          });
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // aquery() {
    //   let data = {
    //     landid: this.value,
    //     stype: 2,
    //     Atype: 0,
    //   };
    //   // console.log(data);
    //   API_GET_LIST(data)
    //     .then((res) => {
    //       console.log(res);
    //       this.optionInfo = res.ResList;
    //       res.ResList.map((item) => {
    //         this.option.push({
    //           value: item.ApplyGroupid,
    //           label: item.ApplyGroupid,
    //         });
    //       });
    //     })
    //     .catch((err) => {
    //       console.log(err);
    //     });
    // },
    /* 获取征地项目列表 */
    submitProjectName() {
      API_GET_LAND()
        .then((res) => {
          this.options = res.ResList;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    number_format(number, decimals, dec_point, thousands_sep) {
      /*
       * 参数说明：
       * number：要格式化的数字
       * decimals：保留几位小数
       * dec_point：小数点符号
       * thousands_sep：千分位符号
       *
       */
      number = (number + "").replace(/[^0-9+-Ee.]/g, "");
      var n = !isFinite(+number) ? 0 : +number,
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = typeof thousands_sep === "undefined" ? "," : thousands_sep,
        dec = typeof dec_point === "undefined" ? "." : dec_point,
        s = "",
        toFixedFix = function (n, prec) {
          var k = Math.pow(10, prec);
          return "" + parseInt(n * k) / k;
        };
      s = (prec ? toFixedFix(n, prec) : "" + parseInt(n)).split(".");
      var re = /(-?\d+)(\d{3})/;
      while (re.test(s[0])) {
        s[0] = s[0].replace(re, "$1" + sep + "$2");
      }
      if ((s[1] || "").length < prec) {
        s[1] = s[1] || "";
        s[1] += new Array(prec - s[1].length + 1).join("0");
      }
      return s.join(dec);
    },
  },
  created() {
    this.submitProjectName();
    this.user_name = localStorage.getItem("user");
    this.nowTime = new Date()
      .toLocaleDateString()
      .replace("/", "-")
      .replace("/", "-");
  },
};
</script>

<style scoped lang="scss">
.accountsubsidy {
  padding: 30px;
  .el-pagination {
    // max-width: 1513px;
    text-align: right;
    margin-top: 10px;
  }
  ::v-deep .el-input.is-disabled .el-input__inner {
    text-align: right;
  }

  /* 打印的东西隐藏起来 */
  @media only screen {
    #printTest {
      display: none;
    }
  }
  .el-table__header tr,
  .el-table__header th {
    padding: 0 !important;
    height: 45px !important;
    line-height: 45px !important;
  }
}
</style>
